<template>
	<view>
		<nav-bar   fontColor="#FFFFFF" title="入库登记">
			<view slot="right" @click="scanQrCode">
				<image src="../../static/icon/scan-white.png" style="width: 50rpx;height: 50rpx;margin-right: 25upx;">
				</image>
			</view>
		</nav-bar>
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<uni-section title="表单" type="line">
			<view class="example">
				<!-- 基础用法，不包含校验规则 -->
				<uni-forms ref="baseForm" :model="baseFormData" labelWidth="80px" labelPosition="top">
					<uni-forms-item label="收货单号">
						<uni-easyinput v-model="baseFormData.orderNo" placeholder="请输入收货单号" />
					</uni-forms-item>
					<uni-forms-item label="OMS号">
						<uni-easyinput v-model="baseFormData.sourceOrderNo" placeholder="请输入OMS号" />
					</uni-forms-item>
					<uni-forms-item label="客户单号">
						<uni-easyinput v-model="baseFormData.receiptNo" placeholder="请输入客户单号" />
					</uni-forms-item>
					<uni-forms-item label="客户代码" required>
						<uni-easyinput v-model="baseFormData.customerNo" suffixIcon="search" placeholder="请输入客户代码"
							@iconClick="customerSelect"></uni-easyinput>
					</uni-forms-item>
					<uni-forms-item label="客户名称" required>
						<uni-easyinput v-model="baseFormData.customerName" placeholder="请输入客户名称" />
					</uni-forms-item>

					<uni-forms-item label="订单日期">
						<uni-datetime-picker type="date" return-type="timestamp" v-model="baseFormData.orderTime" />
					</uni-forms-item>
					<uni-forms-item labelWidth="80" label="预期收货日期">
						<uni-datetime-picker type="date" return-type="timestamp"
							v-model="baseFormData.preArrivedTime" />
					</uni-forms-item>
					<!-- <uni-forms-item label="状态" required>
						<uni-data-select v-model="baseFormData.skills" :localdata="skillsRange">
						</uni-data-select>
					</uni-forms-item> -->
					<uni-forms-item label="订单类型">
						<uni-data-select v-model="baseFormData.orderType" :localdata="orderTypeList">
						</uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="发运地代码">
						<uni-data-select placeholder="请输入发运地代码" v-model="baseFormData.warehouseCode"
							:localdata="warehouseList" @change="customerAtSelectChange">
						</uni-data-select>
						<!-- <uni-easyinput v-model="baseFormData.warehouseCode" placeholder="请输入发运地代码" /> -->
					</uni-forms-item>
					<uni-forms-item label="城市" required>
						<pick-regions :defaultRegion="defaultRegion" @getRegion="handleGetRegion">
							<view style="border: 1px solid #DCDFE6;height: 70rpx;border-radius: 4px;">
								<view v-if="!regionName"
									style="color: #c5c5c5;font-size: 24rpx;line-height: 70rpx;margin-left: 20rpx;">请选择城市
								</view>
								<view v-else
									style="color: #000000;font-size: 24rpx;line-height: 70rpx;margin-left: 20rpx;">
									{{regionName}}
								</view>
							</view>
						</pick-regions>
					</uni-forms-item>
					<uni-forms-item label="地址">
						<uni-easyinput v-model="baseFormData.shipperAddress" placeholder="请输入地址" />
					</uni-forms-item>
					<uni-forms-item label="电话">
						<uni-easyinput v-model="baseFormData.shipperPhoneNo" placeholder="请输入电话" />
					</uni-forms-item>
					<uni-forms-item label="联系人">
						<uni-easyinput v-model="baseFormData.shipperContact" placeholder="请输入联系人" />
					</uni-forms-item>
					<uni-forms-item labelWidth="80" label="订单处理类型">
						<uni-data-select v-model="baseFormData.orderHandlingType" :localdata="orderHandlingTypeList">
						</uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="备注 " required>
						<uni-easyinput type="textarea" v-model="baseFormData.remark" placeholder="请输入备注 " />
					</uni-forms-item>
				</uni-forms>
			</view>
		</uni-section>




		<uni-section style="margin-top: 20rpx;" title="明细" type="line">
			<lsj-upload ref="lsjUpload" childId="upload1" :option="option" :size="size" :formats="formats"
				:instantly="instantly" @change="onChange">
				<button type="primary" size="mini" style="float: right;margin-right: 20rpx;">上传附件</button>
			</lsj-upload>
			<uni-collapse v-for="(item,index) in baseFormData.itemList" ref="collapse">
				<uni-swipe-action-item>
					<uni-collapse-item :title="'序号-'+ (index + 1)" :open="true">
						<view class="example">
							<uni-forms :model="baseFormData.itemList[index]" ref="baseForm" labelWidth="80px">
								<uni-forms-item label="结算依据">
									<uni-data-select v-model="item.shipByPackOrqty" :localdata="settledBasedOnList"
										placeholder="请输入结算依据">
									</uni-data-select>
								</uni-forms-item>

								<uni-forms-item label="货物名称">
									<uni-easyinput v-model="item.materialName" suffixIcon="search" placeholder="请输入货物名称"
										@iconClick="customerSelects(index)"></uni-easyinput>
								</uni-forms-item>
								<uni-forms-item label="图号">
									<uni-easyinput v-model="item.skuCode" placeholder="请输入图号" />
								</uni-forms-item>
								<uni-forms-item label="货物单价">
									<uni-easyinput v-model="item.unitPrice" placeholder="请输入货物单价" />
								</uni-forms-item>
								<uni-forms-item label="重量单位" v-if="item.shipByPackOrqty === 'weight'">
									<uni-easyinput v-model="item.weightMeasUnit" placeholder="重量单位" />
								</uni-forms-item>
								<uni-forms-item label="重量" v-if="item.shipByPackOrqty === 'weight'">
									<uni-easyinput @blur="handleCalShipmentExpense(index)" v-model="item.unitWeight"
										placeholder="请输入重量" />
								</uni-forms-item>
								<!-- <uni-forms-item label="货物状态">
									<uni-easyinput v-model="item.orderPick" placeholder="请输入货物状态" />
								</uni-forms-item> -->
								<uni-forms-item label="数量" v-if="item.shipByPackOrqty === 'weight'">
									<uni-easyinput type="number" @blur="handleCalShipmentExpense(index)"
										v-model="item.quantity" placeholder="请输入数量" />
								</uni-forms-item>
								<uni-forms-item label="总重" v-if="item.shipByPackOrqty === 'weight'">
									<uni-easyinput @blur="handleCalShipmentExpense(index)" v-model="item.weight"
										placeholder="请输入总重" />
								</uni-forms-item>
								<uni-forms-item label="单位体积" v-if="item.shipByPackOrqty === 'vol'">
									<uni-easyinput @blur="handleCalShipmentExpense(index)" v-model="item.unitVolume"
										placeholder="请输入单位体积" />
								</uni-forms-item>
								<uni-forms-item label="总体积" v-if="item.shipByPackOrqty === 'vol'">
									<uni-easyinput @blur="handleCalShipmentExpense(index)" v-model="item.volume"
										placeholder="请输入总体积" />
								</uni-forms-item>

								<uni-forms-item label="长" v-if="item.shipByPackOrqty === 'vol'">
									<uni-easyinput v-model="item.length" placeholder="请输入长" />
								</uni-forms-item>
								<uni-forms-item label="宽" v-if="item.shipByPackOrqty === 'vol'">
									<uni-easyinput v-model="item.width" placeholder="请输入宽" />
								</uni-forms-item>
								<uni-forms-item label="高" v-if="item.shipByPackOrqty === 'vol'">
									<uni-easyinput v-model="item.high" placeholder="请输入高" />
								</uni-forms-item>

								<uni-forms-item label="包装单位" v-if="item.shipByPackOrqty === 'pack'">
									<uni-easyinput v-model="item.packing" placeholder="请输入包装单位" />
								</uni-forms-item>

								<uni-forms-item label="每包装数量" v-if="item.shipByPackOrqty === 'pack'">
									<uni-easyinput v-model="item.qtyPerPack" placeholder="请输入每包装数量" />
								</uni-forms-item>

								<uni-forms-item label="包装(件)" v-if="item.shipByPackOrqty === 'pack'">
									<uni-easyinput v-model="item.packQty" @blur="handleCalShipmentExpense(index)"
										placeholder="请输入包装(件)" />
								</uni-forms-item>
								<uni-forms-item label="价值">
									<uni-easyinput v-model="item.cargoValue" placeholder="请输入价值" />
								</uni-forms-item>
								<uni-forms-item label="结算单价">
									<uni-easyinput @blur="handleSettleExpense(index)" v-model="item.countPrice"
										placeholder="请输入结算单价" />
								</uni-forms-item>
								<uni-forms-item label="结算数量">
									<uni-easyinput @blur="handleSettleExpense(index)" v-model="item.countQuantity"
										placeholder="请输入结算数量" />
								</uni-forms-item>
								<uni-forms-item label="仓储总费">
									<uni-easyinput v-model="item.countCarriage" placeholder="请输入仓储总费" />
								</uni-forms-item>
							</uni-forms>
						</view>
					</uni-collapse-item>
					<template v-slot:right v-if="baseFormData.itemList.length>1">
						<view class="slot-button" @click="deleteInfo(index)"><text class="slot-button-text">删除</text>
						</view>
					</template>
				</uni-swipe-action-item>

			</uni-collapse>
			<view style="padding: 20rpx 0;">
				<button @click="additemList"
					style="width: 90%;margin: 0 auto;background: #3B5DE0;color: #FFFFFF;">新增</button>
			</view>
			<view style="padding: 20rpx 0;">
				<button @click="submit"
					style="width: 90%;margin: 0 auto;background: #3B5DE0;color: #FFFFFF;">提交</button>
			</view>
		</uni-section>
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog :deleteIcon="true" :chooseData="chooseData" :dataList="textData" title="客户代码"
				ref="inputClose" @confirm="confirm" mode="scroll">
			</uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="inputDialogs" type="dialog">
			<uni-popup-customer-dialog :deleteIcon="true" :chooseData="materialData" :dataList="materialTextData"
				title="货物选择" ref="inputCloses" @confirm="confirms" mode="scroll">
			</uni-popup-customer-dialog>
		</uni-popup>
		<uni-popup ref="message" type="message">
			<uni-popup-message :type="msgType" :message="messageText" :duration="1000"></uni-popup-message>
		</uni-popup>
	</view>
</template>

<script>
	const CHINA_REGIONS = require('@/components/pick-regions/regions.json')
	export default {
		data() {
			return {
				option: {
					// 上传服务器地址，需要替换为你的接口地址
					url: 'http://hl.j56.com/dropbox/document/upload', // 该地址非真实路径，需替换为你项目自己的接口地址
					// 上传附件的key
					name: 'file',
					// 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
					header: {
						// 示例参数可删除
						'Authorization': 'bearer eyJhbGciOiJSUzI1NiIsI',
						'uid': '99',
						'client': 'app',
						'accountid': 'DP',
					},
					// 根据你接口需求自定义body参数
					formData: {
						// 'orderId': 1000
					}
				},
				msgType: 'success',
				messageText: '这是一条成功提示',
				// 选择文件后是否立即自动上传，true=选择后立即上传
				instantly: true,
				// 限制允许上传的格式，空串=不限制，默认为空
				formats: '',
				// 文件上传大小限制
				size: 30,
				// 文件数量限制
				count: 2,
				// 文件回显列表
				files: new Map(),
				baseFormData: {
					consignmentLocation: null,
					orderNo: null, //收货单号
					sourceOrderNo: null, //OMS号
					customerNo: '', //客户代码
					customerName: null,
					receiptNo: null, //客户单号
					orderTime: null, //订单日期
					preArrivedTime: null, //预计收货日期
					orderType: null, //订单类型
					warehouseCode: null, //发运地代码
					shipperAddress: null, //地址
					shipperPhoneNo: null, //电话
					shipperContact: null, //联系人
					orderHandlingType: null, //订单处理类型
					remark: null, //备注
					departureIdList: [],
					itemList: [{
						skuCode: null,//图号
						spec:null,//货物规格
						materialName: null,
						materialNo: null,
						measUnitNo: null,
						stageNo: null,
						shipByPackOrqty: null,
						arrivedQty: null,
						qtyPerPack: null,
						quantity: null,
						status: null,
						packQty: null,
						weight: null,
						volume: null,
						countCarriage: null,
						cargoValue: null,
						weightMeasUnit: null,
						packing: null,
						unitPrice: null,
						unitVolume: null,
						unitWeight: null,
						countPrice: null,
						length: null,
						width: null,
						high: null
						// shipByPackOrqty: null, //结算依据
						// quantity: null, //数量
						// materialName: null, //货物名称
						// materialNo: null,
						// unitPrice: null, //货物单价
						// weightMeasUnit: null, //重量单位
						// unitWeight: null, //重量
						// weight: null, //总重
						// cargoValue: null, //价值
						// countPrice: null, //结算单价
						// countQuantity: null, //结算数量
						// countCarriage: null, //仓储总费
						// status: '', //状态
						// allocated: '', //已分配
						// orderPick: '', //已拣货
						// forwarding: '', //已发运
						// stockout: '' //预缺货数
					}]
				},
				region: [],
				defaultRegion: ['广东省', '广州市', '番禺区'],
				defaultRegionCode: '440000',
				chooseData: [],
				materialData: [],
				settledBasedOnList: [{
						text: '重量',
						value: 'weight'
					},
					{
						text: '体积',
						value: 'vol'
					},
					{
						text: '数量',
						value: 'qty'
					},
					{
						text: '包装',
						value: 'pack'
					}
				],
				orderHandlingTypeList: [{
						text: '重量',
						value: 'weight'
					},
					{
						text: '体积',
						value: 'vol'
					},
					{
						text: '数量',
						value: 'qty'
					},
					{
						text: '包装',
						value: 'pack'
					}
				],
				orderTypeList: [{
						text: '重量',
						value: 'weight'
					},
					{
						text: '体积',
						value: 'vol'
					},
					{
						text: '数量',
						value: 'qty'
					},
					{
						text: '包装',
						value: 'pack'
					}
				],
				warehouseList: [],
				textData: [],
				materialTextData: [],
				materialIndex: null
			}
		},
		onLoad() {
			this.loadData();
		},
		computed: {
			regionName() {
				// 转为字符串
				return this.region.map(item => item.name).join('/')
			}
		},
		methods: {
			confirm() {
				if (this.chooseData != '') {
					this.baseFormData.customerNo = this.chooseData[0].id
					this.baseFormData.customerName = this.chooseData[0].customerName
					this.baseFormData.customerPhone = this.chooseData[0].phone
					this.baseFormData.customerAddress = this.chooseData[0].address
					this.baseFormData.consignmentLocation = this.chooseData[0].areaDesc
					if (this.baseFormData.consignmentLocation) {
						this.baseFormData.departureIdList = this.data.consignmentLocation.split(',')
					}
					/*  this.$refs.warehouseCustomerSelector.loadData() */
					this.customerAtChange()
				}
				this.$refs.inputDialog.close();
				console.log(this.chooseData)
			},
			scanQrCode() {

				uni.scanCode({
					success: (res) => {
						console.log(res);
						this.msg = res.result
						let codeData = res.result;
						let dataList = codeData.split('-');
						if (this.baseFormData.itemList.length == 1 && dataList[1] != null) { //第一次扫
							//记住客户编码，并且填充一个货物进去shipByPackOrqty
							console.log(1)
							this.baseFormData.customerName = dataList[0]
							this.baseFormData.customerNo = dataList[1]
							this.baseFormData.itemList[0].materialName = dataList[2]
							this.baseFormData.itemList[0].materialNo = dataList[3]
							this.baseFormData.itemList[0].shipByPackOrqty = dataList[4]
							this.baseFormData.itemList[0].spec = dataList[5]
							this.baseFormData.itemList[0].skuCode = dataList[6]
						} else if (this.baseFormData.customerNo != dataList[1]) { //扫不同的客户二维码
							this.messageToggle('error', '必须扫同样客户的货物')
							return;
						} else if (this.baseFormData.customerNo === dataList[1]) { //扫同样客户的二维码
							//新增一个明细。填充进去
							console.log(2)
							this.additemList();
							let index = this.baseFormData.itemList.length - 1;
							this.baseFormData.itemList[index].materialName = dataList[2]
							this.baseFormData.itemList[index].materialNo = dataList[3]
							this.baseFormData.itemList[index].shipByPackOrqty = dataList[4]
							this.baseFormData.itemList[index].spec = dataList[5]
							this.baseFormData.itemList[index].skuCode = dataList[6]
						} else {
							this.messageToggle('error', '扫描内容异常')
						}
					},
					fail: (rej) => {
						this.messageToggle('error', '扫描异常')
					}
				})
			},
			confirms() {
			//货物选择
				if (this.materialData != '') {
					this.baseFormData.itemList[this.materialIndex].materialName = this.materialData[0].skuName,
					this.baseFormData.itemList[this.materialIndex].skuCode = this.materialData[0].skuCode,
						// this.baseFormData.itemList[this.materialIndex].shipByPackOrqty = this.materialData[0].shipByPackOrqty,
						this.baseFormData.itemList[this.materialIndex].materialNo = this.materialData[0].materialNo,
						this.baseFormData.itemList[this.materialIndex].qtyPerPack = this.materialData[0].convertQuantity,
						this.baseFormData.itemList[this.materialIndex].packing = this.materialData[0].measUnitNo,
						this.baseFormData.itemList[this.materialIndex].unitVolume = this.materialData[0].unitVolume,
						this.baseFormData.itemList[this.materialIndex].unitWeight = this.materialData[0].unitWeight,
						this.baseFormData.itemList[this.materialIndex].measUnitNo = this.materialData[0].measUnitNo,
						this.baseFormData.itemList[this.materialIndex].unitPrice = this.materialData[0].unitPrice
					if (this.materialData[0].shipByPackOrqty != null && this.materialData[0].shipByPackOrqty != "") {
						if (this.materialData[0].shipByPackOrqty === "weight") {
							this.baseFormData.itemList[this.materialIndex].weightMeasUnit = this.materialData[0].measUnitNo

						} else if (this.materialData[0].shipByPackOrqty === "vol") {
							this.baseFormData.itemList[this.materialIndex].measUnitNo = this.materialData[0].measUnitNo
						} else if (this.materialData[0].shipByPackOrqty === "pack") {
							this.baseFormData.itemList[this.materialIndex].packing = this.materialData[0].measUnitNo
						} else {
							this.baseFormData.itemList[this.materialIndex].measUnitNo = this.materialData[0].measUnitNo
						}
					}
				}
				this.$refs.inputDialogs.close();
			},
			customerAtChange() {
				let opt = {
					url: 'pms/tWhWarehouseCustomer/search',
					method: 'POST'
				};
				let params = {
					customerNo: this.baseFormData.customerNo
				}
				this.baseFormData.warehouseCode = ""
				this.baseFormData.shipperAddress = ""
				this.baseFormData.shipperPhoneNo = ""
				this.baseFormData.shipperContact = ""
				this.baseFormData.consignmentLocation = ""
				this.baseFormData.departureIdList = ""

				this.$http.httpTokenRequest(opt, params).then(response => {
					for (let i in response.data.data) {
						this.warehouseList.push({
							"text": response.data.data[i].warehouseName,
							"value": response.data.data[i].id
						})
						console.log(this.warehouseList)
					}
					if (response.data.data != null && response.data.data.length > 0) {
						this.baseFormData.warehouseCode = response.data.data[0].id
						this.baseFormData.shipperAddress = response.data.data[0].address
						this.baseFormData.shipperPhoneNo = response.data.data[0].mobile
						this.baseFormData.shipperContact = response.data.data[0].manager
						this.baseFormData.consignmentLocation = response.data.data[0].locationCity
						if (this.baseFormData.consignmentLocation) {
							this.baseFormData.departureIdList = this.baseFormData.consignmentLocation.split(',')
							console.log(CHINA_REGIONS)
							let regionsData = [];
							for (let i in CHINA_REGIONS) {
								if (CHINA_REGIONS[i].code == this.baseFormData.departureIdList[0]) {
									regionsData.push({
										code: CHINA_REGIONS[i].code,
										name: CHINA_REGIONS[i].name
									});
									for (let j in CHINA_REGIONS[i].childs) {
										if (CHINA_REGIONS[i].childs[j].code == this.baseFormData.departureIdList[
												1]) {
											regionsData.push({
												code: CHINA_REGIONS[i].childs[j].code,
												name: CHINA_REGIONS[i].childs[j].name
											});
											for (let k in CHINA_REGIONS[i].childs[j].childs) {
												if (CHINA_REGIONS[i].childs[j].childs[k].code == this.baseFormData
													.departureIdList[2]) {
													regionsData.push({
														code: CHINA_REGIONS[i].childs[j].childs[k].code,
														name: CHINA_REGIONS[i].childs[j].childs[k].name
													});
												}
											}
										}
									}

								}
							}
							this.region = regionsData
							console.log(regionsData)
						}
					}

				})
			},
			customerSelect() {
				this.chooseData = [];
				this.$refs.inputDialog.open();
			},
			customerSelects(e) {
				this.materialIndex = e;
				this.materialData = [];
				let opt = {
					url: 'pms/tWhWarehouseCustomerMaterial/search',
					method: 'POST'
				};
				let params = {
					customerNo: this.baseFormData.customerNo
				};
				this.$http.httpTokenRequest(opt, params).then(res => {
					this.materialTextData = res.data.data
				})
				this.$refs.inputDialogs.open();
			},
			customerAtSelectChange(e) {
				console.log(e)
				if (this.baseFormData.warehouseCode) {
					let opt = {
						url: 'pms/tWhWarehouseCustomer/' + e,
						method: 'GET'
					};
					this.$http.httpTokenRequest(opt).then(response => {
						if (response.data.data != null) {
							console.log(response)
							this.baseFormData.warehouseCode = response.data.data.id
							this.baseFormData.shipperAddress = response.data.data.address
							this.baseFormData.shipperPhoneNo = response.data.data.mobile
							this.baseFormData.shipperContact = response.data.data.manager
							this.baseFormData.consignmentLocation = response.data.data.locationCity
							if (this.baseFormData.consignmentLocation) {
								this.baseFormData.departureIdList = this.baseFormData.consignmentLocation.split(
									',')
								console.log('*' + this.baseFormData.departureIdList)
								console.log(CHINA_REGIONS)
								let regionsData = [];
								for (let i in CHINA_REGIONS) {
									if (CHINA_REGIONS[i].code == this.baseFormData.departureIdList[0]) {
										regionsData.push({
											code: CHINA_REGIONS[i].code,
											name: CHINA_REGIONS[i].name
										});
										for (let j in CHINA_REGIONS[i].childs) {
											if (CHINA_REGIONS[i].childs[j].code == this.baseFormData
												.departureIdList[1]) {
												regionsData.push({
													code: CHINA_REGIONS[i].childs[j].code,
													name: CHINA_REGIONS[i].childs[j].name
												});
												for (let k in CHINA_REGIONS[i].childs[j].childs) {
													if (CHINA_REGIONS[i].childs[j].childs[k].code == this
														.baseFormData.departureIdList[2]) {
														regionsData.push({
															code: CHINA_REGIONS[i].childs[j].childs[k]
																.code,
															name: CHINA_REGIONS[i].childs[j].childs[k].name
														});
													}
												}
											}
										}

									}
								}
								this.region = regionsData
								console.log(regionsData)
							}
						}
					})
				}
			},
			handleGetRegion(region) {
				console.log(region.map(item => item.name).join('/'))
				this.baseFormData.departureIdList = [];
				for (let i in region) {
					this.baseFormData.departureIdList.push(region[i].code)
				}
				this.baseFormData.consignmentLocation = this.baseFormData.departureIdList.join(',')
				this.region = region
				console.log(region)
			},
			loadData() {
				let opt = {
					url: 'basic/customer/search/1/10',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					this.textData = res.data.data.records
					console.log(this.textData);
				})
			},
			additemList() {
				this.baseFormData.itemList.push({
					materialName: null,
					materialNo: null,
					skuCode: null,//图号
					spec:null,
					measUnitNo: null,
					stageNo: null,
					shipByPackOrqty: null,
					arrivedQty: null,
					qtyPerPack: null,
					quantity: null,
					status: null,
					packQty: null,
					weight: null,
					volume: null,
					countCarriage: null,
					cargoValue: null,
					weightMeasUnit: null,
					packing: null,
					unitPrice: null,
					unitVolume: null,
					unitWeight: null,
					countPrice: null,
					length: null,
					width: null,
					high: null
				})
			},
			handleSettleExpense(e) {
				// let that = this;
				if (this.baseFormData.itemList[e].countQuantity) {

					this.baseFormData.itemList[e].countCarriage = this.baseFormData.itemList[e].countQuantity * this
						.baseFormData.itemList[e].countPrice

				}
			},
			handleCalShipmentExpense(e) {

				console.log(this.baseFormData.itemList)
				// let that = this;
				if (this.baseFormData.itemList[e].shipByPackOrqty) {
					if (this.baseFormData.itemList[e].quantity) {
						this.baseFormData.itemList[e].cargoValue = this.baseFormData.itemList[e].quantity * this
							.baseFormData.itemList[e].unitPrice
						console.log(this.baseFormData.itemList[e].cargoValue)
						// this.$set(this.baseFormData.itemList[0],this.baseFormData.itemList[0].cargoValue,this.baseFormData.itemList[e].quantity * this.baseFormData.itemList[e].unitPrice)
					}
					if (this.baseFormData.itemList[e].shipByPackOrqty === 'weight') {

						if (this.baseFormData.itemList[e].unitWeight) {

							this.baseFormData.itemList[e].countQuantity = this.baseFormData.itemList[e].quantity * this
								.baseFormData.itemList[e].unitWeight
							this.baseFormData.itemList[e].weight = this.baseFormData.itemList[e].quantity * this
								.baseFormData.itemList[e].unitWeight

						}
					} else if (this.baseFormData.itemList[e].shipByPackOrqty === 'qty') {
						if (this.baseFormData.itemList[e].quantity) {
							this.baseFormData.itemList[e].countQuantity = this.baseFormData.itemList[e].quantity
						}
					} else if (this.baseFormData.itemList[e].shipByPackOrqty === 'pack') {
						if (this.baseFormData.itemList[e].packQty) {
							this.baseFormData.itemList[e].countQuantity = this.baseFormData.itemList[e].packQty
							this.baseFormData.itemList[e].quantity = this.baseFormData.itemList[e].packQty * this
								.baseFormData.itemList[e].qtyPerPack
						}
					} else {
						if (this.baseFormData.itemList[e].unitVolume) {

							this.baseFormData.itemList[e].countQuantity = this.baseFormData.itemList[e].quantity * this
								.baseFormData.itemList[e].unitVolume
							this.baseFormData.itemList[e].volume = this.baseFormData.itemList[e].quantity * this
								.baseFormData.itemList[e].unitVolume
						}
					}

				} else {
					this.baseFormData.itemList[e].countQuantity = 0
				}
			},
			deleteInfo(e) {
				this.baseFormData.itemList.splice(e, 1)
				console.log(this.baseFormData.itemList)
			},
			submit() {
				let opt = {
					url: 'web/tbWmsMaterialReceipt/insertAll',
					method: 'POST'
				};
				console.log(this.baseFormData)
				this.$http.httpTokenRequest(opt, this.baseFormData).then(res => {
					if (res.data.code == 200) {
						this.messageToggle('success', res.data.msg)
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
						}, 2000);
						9
					} else {
						this.messageToggle('error', res.data.msg)
					}
				})
			},
			messageToggle(type, msg) {
				this.msgType = type
				this.messageText = msg
				this.$refs.message.open();
			},
			onChange(files) {
				console.log('当前选择的文件列表：', JSON.stringify([...files.values()]));
				// 更新选择的文件 
				this.files = files;
				// 强制更新视图
				this.$forceUpdate();

				// 微信小程序Map对象for循环不显示，所以转成普通数组，不要问为什么，我也不知道
				// #ifdef MP-WEIXIN
				this.wxFiles = [...this.files.values()];
				// #endif
			}
		}
	}
</script>

<style>
	page {
		background: #f5f5f5;
	}

	.content {
		padding: 20rpx;
	}

	.example {
		padding: 20rpx;
		background: #fff;
	}

	.content-box {
		flex: 1;
		/* #ifdef APP-NVUE */
		justify-content: center;
		/* #endif */
		height: 44px;
		line-height: 44px;
		padding: 0 15px;
		position: relative;
		background-color: #fff;
		border-bottom-color: #f5f5f5;
		border-bottom-width: 1px;
		border-bottom-style: solid;
	}

	.content-text {
		font-size: 15px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding: 10px 0;
		background-color: #fff;
	}

	.button {
		border-color: #e5e5e5;
		border-style: solid;
		border-width: 1px;
		padding: 4px 8px;
		border-radius: 4px;
	}

	.button-text {
		font-size: 15px;
	}

	.slot-button {
		/* #ifndef APP-NVUE */
		display: flex;
		height: 100%;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 0 20px;
		background-color: #ff5a5f;
	}

	.slot-button-text {
		color: #ffffff;
		font-size: 14px;
	}
</style>